window.addEventListener('load', function() {
    function animate(obj, target) {
        clearInterval(obj.timer);
        obj.timer = setInterval(function() {
            var step = (target - obj.offsetLeft) / 10;
            if (target < 0) {
                if (obj.offsetLeft <= target) {
                    clearInterval(obj.timer);
                }
            } else {
                if (obj.offsetLeft >= target) {
                    clearInterval(obj.timer);
                }
            }
            obj.style.left = obj.offsetLeft + step + 'px';
            console.log('timer');
        }, 30);
    }
})